package com.client.act;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.client.act.R;
import com.clinet.cache.Log;

public class MyBroadcastReceiver extends BroadcastReceiver {
	public static int count=0;
	public void onReceive(Context context, Intent intent) {
//		if (intent.getAction().equals(APNService.ON_NOTIFICATION)) {
//			String str = intent.getStringExtra("data"); // todo, 处理收到的消息
//			Log.i("MyBroadcastReceiver onReceive--------"+str);
//			showNotification(context,str);
//		}
	}

	private void showNotification(Context context,String s) {
		count+=1;;
		Log.i("MyBroadcastReceiver showNotification--------"+s);
		NotificationManager mNotificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
		long when = System.currentTimeMillis();
		Intent notificationIntent = new Intent(context,CollectionGridAct.class);
		PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
				notificationIntent, 0);
		Notification notification = new Notification(R.drawable.icon, "Received Notification"+count, when);
		notification.defaults = Notification.DEFAULT_VIBRATE;
		notification.setLatestEventInfo(context, "Received Notification", s,
				contentIntent);
		notification.flags |= Notification.FLAG_AUTO_CANCEL;
		mNotificationManager.notify(0, notification);
	}
}
